Menu
Back to Explore Page
Subarray with given sum
Check for BST
Minimum number of jumps
Kadane's Algorithm
Left View of Binary Tree
Remove loop in Linked List
Minimize the Heights II
Missing number in array
Detect Loop in linked list
Find duplicates in an array
Kth smallest element
Sort an array of 0s, 1s and 2s
Nth node from end of linked list
Majority Element
Finding middle element in a linked list
Detect cycle in a directed graph
Reverse a linked list
Check if Linked List is Palindrome
Peak element
Detect cycle in an undirected graph
Given a string str. The task is to find the maximum occurring character in the string str. If more than one character occurs the maximum number of time then print the lexicographically smaller character.
Example 1:
Input: str = testsample Output: e Explanation: e is the character which is having the highest frequency.
Example 2:
Input: str = output Output: t Explanation: t and u are the characters with the same frequency, but t is lexicographically smaller.
Your Task:
The task is to complete the function getMaxOccuringChar() which returns the character which is most occurring.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Number of distinct characters).
Note: N = |s|
Constraints:
1 ≤ |s| ≤ 100
Font Size
Theme
Choose Your Preferred font For The Code Editor
-1655185524.png)